﻿<cfsilent>
	<cfscript>
		
		event.setArg("pageTitle", "教学运行 - 教学场地调度 - 教室借用向导");
		
		mathAdvice = getProperty("serviceFactory").getBean("senateMathAdvice");
		
		termId = event.getArg("TermID");
		academicYear = event.getArg("AcademicYear");
		academicTerm = event.getArg("AcademicTerm");
		termDateStart = event.getArg("DateStart");
		
		
		/* 读取校区信息 */
		sql = "SELECT campus_id, campus_name FROM t_campus ORDER BY campus_id";

		queryObj = new Query( datasource=application.dnsSlave );
			
		rs_campus = queryObj.execute( sql=sql ).getResult();
		
		
		/* 读取可用于借用的教室类别信息 */
		sql = "SELECT cr_type, cr_type_name 
				FROM t_classroom_type 
				WHERE 
					cr_type LIKE '0__' 
					AND 
					substr(cr_usage, 4, 1) = '1'
				ORDER BY cr_type ";
		
		queryObj = new Query( datasource=application.dnsSlave );
			
		rs_room_type = queryObj.execute( sql=sql ).getResult();
		
		
		/* 计算当前教学周 */
		weekStart = mathAdvice.convertTaskWeek( termDateStart, DateFormat( now(), "YYYYMMDD") );
		if ( weekStart lt 1 ) weekStart = 1;
		if ( weekStart gt 18 ) weekStart = 18;
		weekEnd = 18;
		if ( weekStart gt weekEnd ) weekEnd = weekStart;
		
		/* 起始周 */
		w1 = event.getArg("W1", weekStart);
		/* 结束周 */
		w2 = event.getArg("W2", weekStart);
		/* 如果起始周大于结束周则已起始周为结束周 */
		if ( w1 gt w2 ) w2 = w1; 
		/* 星期几 */
		wkday = event.getArg("WKDAY", mathAdvice.convertDayOfWeekToWeekDay( dayOfWeek( now() ) ) );
		/* 时段 */
		wkcell = event.getArg("CELL");
		
		/* 校区 */
		campusId = event.getArg("CAMP", rs_campus.campus_id);

		/* 教室类别 */
		roomType = event.getArg("CT", rs_room_type.cr_type);
		
		/* 教室座位 */
		roomSize = event.getArg("SIZE");

		passArgs = structNew();
		structInsert( passArgs, "W1", w1 );
		structInsert( passArgs, "W2", w2 );
		structInsert( passArgs, "WKDAY", wkday );
		structInsert( passArgs, "CAMP", campusId );
		structInsert( passArgs, "CT", roomType );

		if ( wkcell neq "" ) structInsert( passArgs, "CELL", wkcell );
		if ( roomSize neq "" ) structInsert( passArgs, "SIZE", roomSize );
		
		
		currentTab = event.getArg("Tab", "labCondition");
		
		if ( wkcell neq "" ) currentTab = "labSearch";
		

		
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('DEFAULT_EVENT')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">教学场地调度</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 info"></i>预计使用时段
				</h2>
			</div>
		</div>
	</div>
</div>

<!--- 加载导航菜单 --->
<!-- stepMenu-->
<cfoutput>#event.getArg("stepMenu")#</cfoutput>
<!--/stepMenu-->

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				
				<div class="UItab2">
					<div class="tabLables">
						<span <cfif currentTab eq "labCondition">class="active"</cfif> id="labCondition" tabTarget="Condition">时间及教室类别</span>
						<!--- 若已指定时段 则显示搜索 --->
						<cfif wkcell neq "">
							<span <cfif currentTab eq "labSearch">class="active"</cfif> id="labSearch" tabTarget="Search">查找教室</span>
						</cfif>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				
				<div id="Condition" class="tabContent">
					
					<div class="noticeBlock">
						
						<h3>教室借用时段</h3>
						<hr/>
						
						<div class="UIArrangeOper mtl">
							<b class="lable">校区</b>
							<div class="content">
								<cfloop query="rs_campus">
									<cfset structInsert( passArgs, "CAMP", rs_campus.campus_id, true ) />
									<cfif campusId eq rs_campus.campus_id>
											<span class="opBtn"><cfoutput>#rs_campus.campus_name#</cfoutput></span>
										<cfelse>
											<a class="opBtn" href="<cfoutput>#buildURL('classRoomBorrow', passArgs)#</cfoutput>"><cfoutput>#rs_campus.campus_name#</cfoutput></a>
										</cfif>
								</cfloop>
								<!--- 回滚默认值 --->
								<cfset structInsert( passArgs, "CAMP", campusId, true ) />
							</div>
						</div>
						<div class="UIArrangeOper">
							<b class="lable">教室类别</b>
							<div class="content">
								<cfloop query="rs_room_type">
									<cfset structInsert( passArgs, "CT", rs_room_type.cr_type, true ) />
									<cfif roomType eq rs_room_type.cr_type>
											<span class="opBtn"><cfoutput>#rs_room_type.cr_type_name#</cfoutput></span>
										<cfelse>
											<a class="opBtn" href="<cfoutput>#buildURL('classRoomBorrow', passArgs)#</cfoutput>"><cfoutput>#rs_room_type.cr_type_name#</cfoutput></a>
									</cfif>
								</cfloop>
								<!--- 回滚默认值 --->
								<cfset structInsert( passArgs, "CT", roomType, true ) />
							</div>
						</div>
						
						<div class="UIArrangeOper mtl">
							<b class="lable">起始周</b>
							<div class="content">
								<cfloop from="#weekStart#" to="#weekEnd#" index="w">
									<cfset structInsert( passArgs, "W1", w, true ) />
									<cfif w eq w1>
											<span class="opBtn numeric"><cfoutput>#w#</cfoutput></span>
										<cfelse>
											<a class="opBtn numeric" href="<cfoutput>#buildURL('classRoomBorrow', passArgs)#</cfoutput>"><cfoutput>#w#</cfoutput></a>
									</cfif>
								</cfloop>
								<!--- 回滚默认值 --->
								<cfset structInsert( passArgs, "W1", w1, true ) />
							</div>
						</div>
						<div class="UIArrangeOper">
							<b class="lable">结束周</b>
							<div class="content">
								<cfloop from="#weekStart#" to="#weekEnd#" index="w">
									<cfset structInsert( passArgs, "W2", w, true ) />
									<cfif w eq w2>
											<span class="opBtn numeric"><cfoutput>#w#</cfoutput></span>
										<cfelse>
											<a class="opBtn numeric" href="<cfoutput>#buildURL('classRoomBorrow', passArgs)#</cfoutput>"><cfoutput>#w#</cfoutput></a>
									</cfif>
								</cfloop>
								<!--- 回滚默认值 --->
								<cfset structInsert( passArgs, "W2", w2, true ) />
							</div>
						</div>
						<div class="UIArrangeOper mtl">
							<b class="lable">周次内时段</b>
							<div class="content">
								<cfloop from="1" to="7" index="wk">
									<cfset structInsert( passArgs, "WKDAY", wk, true ) />
									<cfif wk eq wkday>
											<span class="opBtn"><cfoutput>#mathAdvice.convertWeekDayToChinese( wk )#</cfoutput></span>
										<cfelse>
											<a class="opBtn" href="<cfoutput>#buildURL('classRoomBorrow', passArgs)#</cfoutput>"><cfoutput>#mathAdvice.convertWeekDayToChinese( wk )#</cfoutput></a>
									</cfif>
								</cfloop>
								<!--- 回滚默认值 --->
								<cfset structInsert( passArgs, "WKDAY", wkday, true ) />
							</div>
							<div class="content">
								<cfloop from="1" to="6" index="cell">
									<cfset structInsert( passArgs, "CELL", cell, true ) />
									<cfif wkcell eq cell>
											<span class="opBtn"><cfoutput>#mathAdvice.convertLectureIdxToChinese( cell )#</cfoutput></span>
										<cfelse>
											<a class="opBtn" href="<cfoutput>#buildURL('classRoomBorrow', passArgs)#</cfoutput>"><cfoutput>#mathAdvice.convertLectureIdxToChinese( cell )#</cfoutput></a>
									</cfif>
								</cfloop>
								&nbsp;
								<cfloop list="S,X,B,W,Q" index="cell">
									<cfset structInsert( passArgs, "CELL", cell, true ) />
									<cfif wkcell eq cell>
											<span class="opBtn"><cfoutput>#mathAdvice.convertLectureIdxToChinese( cell )#</cfoutput></span>
										<cfelse>
											<a class="opBtn" href="<cfoutput>#buildURL('classRoomBorrow', passArgs)#</cfoutput>"><cfoutput>#mathAdvice.convertLectureIdxToChinese( cell )#</cfoutput></a>
									</cfif>
								</cfloop>
								<!--- 回滚默认值 --->
								<cfset structInsert( passArgs, "CELL", wkcell, true ) />
							</div>
						</div>

					</div>
				
				</div>	

				<!--- 若已指定时段 则显示搜索 --->
				<cfif wkcell neq "">
					
					<div id="Search" class="tabContent">
						
						<div class="noticeBlock">
							<h3>指定教室的座位数</h3>
							<hr/>
						</div>
						
						<form id="formSearch" onSubmit="javascript:return processVerfiyForm('formSearch');" class="formWrapper " method="post" action="<cfoutput>#buildURL('classRoomBorrowRoomList')#</cfoutput>">
							
							<input name="W1" type="hidden" value="<cfoutput>#w1#</cfoutput>" />
							<input name="W2" type="hidden" value="<cfoutput>#w2#</cfoutput>" />
							<input name="WKDAY" type="hidden" value="<cfoutput>#wkday#</cfoutput>" />
							<input name="CAMP" type="hidden" value="<cfoutput>#campusId#</cfoutput>" />
							<input name="CT" type="hidden" value="<cfoutput>#roomType#</cfoutput>" />
							<input name="CELL" type="hidden" value="<cfoutput>#wkcell#</cfoutput>" />
							
							<div class="label">
								<b>使用时段</b>
								<p>
									<cfif w1 eq w2>
										第<cfoutput>#w1#</cfoutput>周
										<cfelse>
										第<cfoutput>#w1#</cfoutput>至<cfoutput>#w2#</cfoutput>周
									</cfif>
									<cfoutput>#mathAdvice.convertWeekDayToChinese(wkday)#</cfoutput>
									<cfoutput>#mathAdvice.convertLectureIdxToChinese(wkcell)#</cfoutput>
								</p>
							</div>
							
							<div class="label">
								<b>选择范围</b>
								<p>
									<cfloop query="rs_campus">
										<cfif campusId eq rs_campus.campus_id>
											<cfoutput>#rs_campus.campus_name#</cfoutput>
										</cfif>
									</cfloop>
									<cfloop query="rs_room_type">
										<cfif roomType eq rs_room_type.cr_type>
											<cfoutput>#rs_room_type.cr_type_name#</cfoutput>
										</cfif>
									</cfloop>
								</p>
							</div>
							
							<div class="label">
								<b>座位数不低于</b>
								<input name="SIZE" id="SIZE" type="text" class="typeTinyInt" verification="integer" maxlength="3" value="<cfoutput>#event.getArg('SIZE', roomSize)#</cfoutput>" />
								<p class="notice">请根据实际的需要填写座位数, 系统会查找满足座位数条件的教室</p>
							</div>
							
							<hr/>
							
							<div class="lable">
								<input class="button1" type="submit" value="查找教室" />
							</div>
							
						</form>
						
					</div>
				</cfif>

			</div>
		</li>
	</ul>
</div>